<template>
	<view class="page-fade-in" :style="{opacity: pageOpc}">
		<template v-if="pageOpc">
			<view class="content">
				<view class="shop-info-box">
					<view class="info-item">
						<textarea placeholder="请输入店长寄语" placeholder-class="placeholderclass" v-model="blessing_txt" maxlength="500"></textarea>
					</view>
				</view>
				<view class="bottom-box flexWrapNo">
					<!-- 已保存 -->
					<view class="define-btn" @tap="setStoreInfo()">确认无误并保存</view>
				</view>
			</view>
		</template>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageOpc:0,
				blessing_txt:""
			}
		},
		onLoad() {
			this.getStoreInfo();
		},
		onReady(){
			setTimeout(() => {
				this.pageOpc=1
			}, 100)
		},
		methods: {
			getStoreInfo(){
				this.$request.post(this.$api.storeInfo, {
					store_id:uni.getStorageSync('store_id')
				}, {
					token:true
				}).then(res => {
					let {
						data = {}
					} = res;
					if (res.code==1) {
						this.blessing_txt=data.blessing_txt
					}
				})
			},
			setStoreInfo(){
				let pages = getCurrentPages(); //当前页
				let beforePage = pages[pages.length - 2]; //上个页面
				beforePage.$vm.blessing_txt=this.blessing_txt
				beforePage.$vm.setStoreInfo()
				setTimeout(()=>{
					uni.navigateBack({delta:1})
				},1000)
			}
		}
	}
</script>

<style lang="scss">
	.content{
		padding: 0 36upx;
		.shop-info-box{
			border-top: 1upx solid #36355E;
			.info-item{
				font-size: 28upx;
				font-family: PingFang SC;
				font-weight: 400;
				line-height: 40upx;
				color: #FFFFFF;
				padding: 30upx 0;
				border-bottom: 1upx solid #36355E;
				textarea{
					background: #1D1C5C;
					border-radius: 16upx;
					padding: 30upx;
					height: 240upx;
					margin-top: 30upx;
					font-size: 28rpx;
				}
				.placeholderclass {
					font-size: 28rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #9191A7;
				}
				&:nth-last-of-type(1){
					border-bottom: none;
				}
				.icon-more{
					border-color: #FFFFFF;
				}
			}
		}
		.bottom-box{
			height: 120rpx;
			background: #1D1C5C;
			position: fixed;
			left: 0;
			right: 0;
			bottom: 0;
			margin: auto;
			justify-content: center;
			font-size: 32rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			.define-btn{
				font-size: 32rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 80rpx;
				width: 322rpx;
				height: 80rpx;
				background: #26BCFD;
				border-radius: 16rpx 16rpx 16rpx 16rpx;
				text-align: center;
			}
		}
	}
</style>
